<template>
<div>
  <component :is="currentView"  keep-alive :keyMap="keyMap" :parentDesignerData='desigerData' :inputParams='params'></component>
</div>
</template>
<script>
import designer from 'views/graph/designer.vue'
export default {
  name: 'shower',
  watch:{

    // 本想watch $route.params ,无法生效，所有 监听 $route.query
    '$route.query'(){
      if (this.$route.params&&this.$route.params.queryData  && this.$route.params.queryData!='' ){
          var queryData = this.decodeParams(this.$route.params.queryData)
          this.desigerData= {
            grsNo:queryData.grsNo
          };
          this.params=queryData.params
        }
     }

  },
  data() {
    return {
      keyMap: {editable:'false'},
      currentView: designer,
      desigerData:{},
      params:{}
    }
  },
  mounted() {
    // console.log(this.$route.query.grsNo);
    // if (this.$route.query && this.$route.query.queryData  && this.$route.query.queryData!='' ){
    //   var queryData = this.decodeParams(this.$route.query.queryData)
    //   // console.log(queryData);
    //   this.desigerData = {
    //     grsNo:queryData.grsNo
    //   };
    //
    //   this.params=queryData.params
    // }
    if (this.$route.query&&this.$route.query.grsNo  && this.$route.query.grsNo!='' ){
       if(this.$route.query.params){
         var params = this.decodeParams(this.$route.query.params);
         this.params=params;
       }
       this.desigerData= {
         grsNo:this.$route.query.grsNo
       };
     }


    if (this.$route.params&&this.$route.params.queryData  && this.$route.params.queryData!='' ){
      var queryData = this.decodeParams(this.$route.params.queryData);
      // console.log(queryData);
      this.desigerData = {
        grsNo:queryData.grsNo
      };

      this.params=queryData.params
    }

  },
  methods: {
    decodeParams(str){
      return eval("(" + str + ")");
    }
  }
}
</script>
